<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/16
 * Time: 13:38
 */
echo '<pre>';
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '123456');
//var_dump($pdo);
$sql = 'select * from `demo` as t1 JOIN (select round(rand() * (select max(id) from `demo`)) as id) as t2 where t1.id>=t2.id order BY t1.id ASC limit 1';
$rows = $pdo->query($sql);
while ($row=$rows->fetch(1)) {
var_dump($row);
}